FROM php:7.1.33-fpm-alpine3.10

MAINTAINER Will <shaoweizheng@163.com|qq252075062>

COPY composer-1.9.0.phar /usr/local/bin/composer
COPY gosu-amd64 /usr/local/bin/gosu
COPY gosu-amd64.asc /usr/local/bin/gosu.asc

WORKDIR /wwwroot

ENV GOSU_VERSION 1.11

RUN set -xeu; \
#    sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories; \
    mv /etc/apk/repositories /etc/apk/repositories.default; \
    echo -e "http://mirrors.aliyun.com/alpine/v3.10/main\nhttp://mirrors.aliyun.com/alpine/v3.10/community" > /etc/apk/repositories; \
    apk update; \
    apk add --no-cache --virtual .build-deps \
        ca-certificates \
        dpkg \
        gnupg \
        libjpeg \
        libjpeg-turbo \
        libjpeg-turbo-dev \
        freetype-dev \
        libxml2-dev; \
    dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \
#    wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch"; \
#    wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc"; \
    export GNUPGHOME="$(mktemp -d)"; \
#    gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \
    gpg --batch --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \
    gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
    command -v gpgconf && gpgconf --kill all || :; \
    rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc; \
    chmod +x /usr/local/bin/gosu; \
    gosu --version; \
    gosu nobody true; \
    docker-php-ext-configure gd \
        --with-freetype-dir=/usr/include/ \
        --with-jpeg-dir=/usr/include/; \
    docker-php-ext-install -j$(nproc) mysqli pdo_mysql opcache sockets soap exif; \
    apk del --no-network .build-deps; \
    apk add --no-cache \
            libpng-dev \
            libzip-dev; \
    docker-php-ext-configure zip \
        --with-libzip; \
    docker-php-ext-install -j$(nproc) gd zip; \
    chmod +x /usr/local/bin/composer; \
    composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/; \
    rm -rf /var/cache/apk/*; \
    rm -rf /var/lib/apk/*; \
    rm -rf /etc/apk/cache/*;
